package zz.note.thread.stop;

/**
 * @Author: ZZ
 * @date 2022/2/18
 */
public class Thread005 extends Thread {
	private volatile boolean flag = true;

	@Override
	public void run() {
		System.out.println(Thread.currentThread().getName());
		while (flag) {
		}
	}

	public void stopThread() {
		this.flag = false;
	}

	public static void main(String[] args) {
		Thread005 thread005 = new Thread005();
		thread005.start();
		try {
			Thread.sleep(3000);
			thread005.stopThread();
		} catch (Exception e) {

		}
	}
}